<?php



/**
 * Widget
 * 
 * @package SM-Market
 * @author LestaD
 * @copyright 2013
 * @version 0.2
 * @access public
 */
class Widget
{
	
	protected $settings;
	
	/**
	 * Widget::__construct()
	 * 
	 * @param mixed $Settings
	 * @return void
	 */
	public function __construct( array $Settings )
	{
		$this->settings = $Settings;
	}
	
	public function __config( &$dblink )
	{
		
	}
	
	
	/**
	 * Widget::create()
	 * 
	 * @param mixed $Name
	 * @param mixed $Settings
	 * @return void
	 */
	static public function create( $Name, &$dblink, array $Settings = array() )
	{
		$path = _WIDGETS . $Name . ".widget.php";
		if ( file_exists( $path ) && is_file( $path ) )
		{
			include $path;
			$Name{0} = strtoupper($Name{0});
			$class = "Widget$Name"; 
			if ( class_exists( $class ) )
			{
				$obj = new $class( $Settings );
				if ( is_a( $obj, __CLASS__ ) )
				{
					$obj->__config( $dblink );
					return $obj;
				}
			}
		}
		
		return false;
	}
	
}



